package com.x.scratch.dao;

import com.x.framework.Base;
import com.x.framework.dao.BaseDao;
import com.x.scratch.model.User;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class UserDao extends BaseDao {
    private final static String selectUserListSql = "select t1.* from scratch_user t1 where 1 = 1 ";

    public List<User> selectUserList(User user) throws Exception {
        StringBuilder sb = new StringBuilder(selectUserListSql);
        List params = new ArrayList();
        if (Base.isNotNull(user.getUserOpenId())) {
            sb.append("and t1.USER_OPEN_ID = ? ");
            params.add(user.getUserOpenId());
        }
        return this.queryForList(sb.toString(), User.class, params);
    }
}
